/**
 * Title:		KFrogDataType.java
 * Description: This class is used as a superclass of all data type subclasses. 
 * 
 * @version		1.0 May 2009
 * @author		Rami Habas
 */

package kfrog.type;

public class KFrogDataType {

	/** name of the variable associated with this instance */
    String name;
    
    /** initialization state of the variable associated with this instance */
    boolean init;

    public KFrogDataType() {
        name = null;
        init = false;
    }
    
    /**
     * Throw an exception if the variable has no name binding.
     */
    void variableCheck() {
        if (name != null)
            return;
        throw new RuntimeException("The object has to be a variable");
    }

    /**
     * Throw an exception if the variable is not initialized.
     */
    void initCheck() {
        if (init)
            return;
        throw new RuntimeException("The object has to be initialized");
    }

    /** generic copy method */
    public KFrogDataType copy() {
        return new KFrogDataType();
    }
    
    /** instantiate a new type */
    public KFrogDataType newType() {
        return new KFrogDataType();
    }

    public String getName() {
        return name;
    }
    
    public void setName(String name){
        this.name = name;
    }

    public String typeName() {
        return "unidentified";
    }

    public String getValue() {
    	throw new RuntimeException("Illegal function call");
    }
    
    /** useful for debug messages */
    public String toString() {
    	
    	String str = typeName();
        
    	if (name !=null)
            str += " " + name;
        
        if (init)
            str += " = " + getValue();
        
        return str;
    }
    
    /** addition */
    public KFrogDataType plus(KFrogDataType b) {
        throw new RuntimeException("The operator + is illegal");
    }

    /** subtraction */
    public KFrogDataType minus(KFrogDataType b) {
        throw new RuntimeException("The operator - is illegal");
    }

    /** multiplication */
    public KFrogDataType times(KFrogDataType b) {
        throw new RuntimeException("The operator * is illegal");
    }

    /** division */
    public KFrogDataType divide(KFrogDataType b) {
        throw new RuntimeException("The operator / is illegal");
    }
    
    /** modulo */
    public KFrogDataType modulo(KFrogDataType b) {
        throw new RuntimeException("The operator % is illegal");
    }
    
    /** prefix increment */
    public KFrogDataType prefixIncrement() {
        throw new RuntimeException("The prefix operator ++ is illegal");
    }

    /** postfix increment */
    public KFrogDataType postfixIncrement() {
        throw new RuntimeException("The postfix operator ++ is illegal");
    }

    /** prefix decrement */
    public KFrogDataType prefixDecrement() {
        throw new RuntimeException("The prefix operator -- is illegal");
    }

    /** postfix decrement */
    public KFrogDataType postfixDecrement() {
        throw new RuntimeException("The postfix operator -- is illegal");
    }

    /** assignment */
    public KFrogDataType assign(KFrogDataType b) {
        throw new RuntimeException("The operation = is illegal");
    }
    
    /** is equal relational operator */
    public KFrogDataType isEqual(KFrogDataType b) {
        throw new RuntimeException("The operator == is illegal");
    }

    /** addition then assignment -> += */
    public KFrogDataType plusAssign(KFrogDataType b) {
        throw new RuntimeException("The operation += is illegal");
    }

    /** subtraction then assignment -> -= */
    public KFrogDataType minusAssign(KFrogDataType b) {
        throw new RuntimeException("The operation -= is illegal");
    }

    /** multiplication then assignment -> *= */
    public KFrogDataType timesAssign(KFrogDataType b) {
        throw new RuntimeException("The operation *= is illegal");
    }

    /** division then assignment -> /= */
    public KFrogDataType divideAssign(KFrogDataType b) {
        throw new RuntimeException("The operation /= is illegal");
    }
    
    /** modulo then assignment -> %= */
    public KFrogDataType moduloAssign(KFrogDataType b) {
        throw new RuntimeException("The operation %= is illegal");
    }

    /** greater than relational operator */
    public KFrogDataType greaterThan(KFrogDataType b) {
        throw new RuntimeException("The operator > is illegal");
    }
    
    /** greater than or equal relational operator */
    public KFrogDataType greaterThanOrEqual(KFrogDataType b) {
        throw new RuntimeException("The operator >= is illegal");
    }
    
    /** less than relational operator */
    public KFrogDataType lessThan(KFrogDataType b) {
        throw new RuntimeException("The operator < is illegal");
    }
    
    /** less than or equal to relational operator */
    public KFrogDataType lessThanOrEqual(KFrogDataType b) {
        throw new RuntimeException("The operator <= is illegal");
    }

    /** boolean operator OR */
    public KFrogDataType or(KFrogDataType b) {
        throw new RuntimeException("The operator OR is illegal");
    }
    
    /** boolean operator AND */
    public KFrogDataType and(KFrogDataType b) {
        throw new RuntimeException("The operator AND is illegal");
    }

    /** not equal relational operator */
    public KFrogDataType notEqual(KFrogDataType b) {
        throw new RuntimeException("The operator NOT= is illegal");
    }
    
    /** unary plus */
    public KFrogDataType unaryPlus() {
        throw new RuntimeException("The unary operator + is illegal");
    }

    /** unary minus */
    public KFrogDataType unaryMinus() {
        throw new RuntimeException("The unary operator - is illegal");
    }

    /** boolean operator NOT */
    public KFrogDataType not() {
        throw new RuntimeException("The logical operator NOT is illegal");
    }
}
